這 客戶端-伺服器程式設計模型 是分散式應用程式的基礎架構。它並非由硬體定義,而是由兩種程序之間的 邏輯交易 所構成。其中一個 客戶端 會主動發出對 資源的請求;另一個 伺服器 則負責管理並提供該資源。
1. 四步驟交易流程
每次互動都遵循嚴格的順序:(1) 客戶端發送請求;(2) 伺服器解析並操作本地資源;(3) 伺服器傳送回應;(4) 客戶端處理接收到的資料(例如,呈現 HTML)。
2. 硬體架構
通訊依賴於 網路適配器,一種輸入/輸出裝置。資料從中央處理器經由 I/O 橋接器 與 系統匯流排 傳送到 主記憶體。在像 http://www.google.com:80這樣的網頁請求中,資料包會穿越這些匯流排,以抵達應用程式碼。
3. 協定抽象
現代應用程式使用 網路字節序(大端序) 以確保一致性。類似 getaddrinfo 的函數可提供 網域名稱至 IP 位址的對應關係 同時保持協定獨立性。
main.py
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
QUESTION 1
What if different networks have different maximum frame sizes (MTUs)?
The packet is discarded by the first router.
Routers and IP software handle fragmentation and reassembly.
The sender must manually resend smaller frames.
The network automatically increases its MTU.
✅ Correct!
Correct! Routers break larger packets into smaller fragments to fit the network's constraints.❌ Incorrect
Protocols handle this automatically through fragmentation and reassembly.QUESTION 2
Can a single physical host run both a client process and a server process simultaneously?
No, it causes a hardware conflict on the I/O Bus.
Yes, network applications are process-level interactions.
Only if it has two separate Network Adapters.
Only if one uses IPv4 and the other uses IPv6.
✅ Correct!
The client-server model is a distributed structure partitioned between processes, not hardware units.❌ Incorrect
A host can run many processes. For example, your PC can run a web browser (client) and a local database (server).QUESTION 3
In the 4-step transaction, what is the server's immediate action after receiving a request?
Render the HTML content.
Send an acknowledgement to the router.
Interpret the request and manipulate resources.
Terminate the connection to save bandwidth.
✅ Correct!
Step 2 involves the server processing the request and fetching or calculating the resource.❌ Incorrect
Rendering is done by the client; sending the response happens in Step 3.QUESTION 4
Which hardware component bridges the Network Adapter to the CPU and Main Memory?
The ALU
The I/O Bridge
The Register File
The USB Controller
✅ Correct!
The I/O Bridge manages the flow of data between the I/O bus (where the adapter sits) and the memory/system buses.❌ Incorrect
The ALU performs calculations; the I/O Bridge manages the data path.QUESTION 5
What is the standard byte order for data transmitted over the Internet?
Little-endian
Network byte order (big-endian)
Host-native order
Bi-endian
✅ Correct!
Network Byte Order is defined as big-endian to ensure cross-platform compatibility.❌ Incorrect
Little-endian is common in x86 hosts, but the network protocol requires Big-endian.Case Study: The 'hostname' Transaction
Analyzing a system command through the Client-Server lens.
A student runs the command
linux> hostname on a terminal. This simple utility follows the client-server model to retrieve the machine's name from the operating system.Q
1. Identify the 'Client Process' and 'Server Process' in this local scenario.
Solution:
The terminal/command process acts as the client requesting the resource. The Operating System kernel acts as the server, managing the system's identity resource.
The terminal/command process acts as the client requesting the resource. The Operating System kernel acts as the server, managing the system's identity resource.
Q
2. Trace the data path when the server returns the 'hostname' string from memory to the display.
Solution:
The data moves from Main Memory through the I/O Bridge, across the I/O Bus to the Graphics Adapter for display on the screen.
The data moves from Main Memory through the I/O Bridge, across the I/O Bus to the Graphics Adapter for display on the screen.
Q
3. If this were a remote request via a web browser, what 'well-known service name' and port would likely be involved?
Solution:
A web browser request typically uses the http service name on port 80.
A web browser request typically uses the http service name on port 80.